package com.accessibleworlds.maps;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

/**
 * Describes the collection of icons placed on specific locations on the map. 
 */
public class MapPinpoint extends ItemizedOverlay<OverlayItem>{
	private ArrayList<OverlayItem> pinpoints;
	
	/**
	 * Creates a new pinpoint collection.
	 * @param defaultMarker The default marker for new pinpoints
	 */
	public MapPinpoint(Drawable defaultMarker) {
		super(boundCenter(defaultMarker));
		pinpoints = new ArrayList<OverlayItem>();
		populate();
	}
	
	@Override
	protected OverlayItem createItem(int i) {
		return pinpoints.get(i);
	}

	@Override
	public int size() {
		return pinpoints.size();
	}
	
	/**
	 * Pins a new icon to the map.
	 * @param item The new icon to be added on the map
	 */
	public void insertOverlayItem(OverlayItem item){
		pinpoints.add(item);
		populate();
	}
	
	/**
	 * Deletes an icon on the map.
	 * @param index The index at which the icon to be deleted resides
	 */
	public void removeOverlayItem(int index) {
		pinpoints.remove(index);
		populate();
	}
}
